#Include gui\main.ahk
#Include getColor.ahk
#Include skills.ahk
#Include Memory.ahk
RunAs('Administrator')
CoordMode('Mouse')
CoordMode('Pixel')
iniPath := A_ScriptDir "\config.ini"
main := mianGui()
color := colorGui()
try{
    memoryClass := Memory()
}
globalHotKeySet()

;取色窗口打开则主窗口隐藏，取色窗口关闭则主窗口显示
mainGuiShoworHide(*) {
    static statusMainGui := false
    statusMainGui := !statusMainGui
    if (statusMainGui) {
        main.Hide()
        ;创建取色窗口
        color.showGui()
        WinActivate('ahk_id' color.Hwnd)
        ;设置取色热键
        statusMainGui := true
    } else {
        main.Show()
        ;销毁取色窗口
        color.Destroy()
        ; clean()
        ;关闭取色热键
        statusMainGui := false
    }
}
;根据热键名称获取热键值,如：侧键上 -> XButton2
getHotkeyValue(KeyName) {
    static keyValue := ''
    if (KeyName = '侧键上')
        keyValue := 'XButton2'
    else if (KeyName = '侧键下')
        keyValue := 'XButton1'
    else if (KeyName = '左键')
        keyValue := 'LButton'
    else if (KeyName = '右键')
        keyValue := 'RButton'
    else if (KeyName = '中键')
        keyValue := 'MButton'
    else
        keyValue := 0
    return keyValue
}
;根据热键值获取热键名称,如：XButton2 -> 侧键上
getHotkeyName(keyValue) {
    static keyName := ''
    if (keyValue = 'XButton2')
        keyName := '侧键上'
    else if (keyValue = 'XButton1')
        keyName := '侧键下'
    else if (keyValue = 'LButton')
        keyName := '左键'
    else if (keyValue = 'RButton')
        keyName := '右键'
    else if (keyValue = 'MButton')
        keyName := '中键'
    else
        keyName := ''
    return keyName
}

main.Initialization()
skill := main.getCareeSkill()
skill.hotKeyBind()

;隐藏/显示主窗口
F1:: {
    static isShow := true
    isShow := !isShow
    if (isShow) {
        main.Show()
        isShow := true
    } else {
        main.Hide()
        isShow := false
    }
}